package ModelLayer;
import java.util.ArrayList;

/**
 * Write a description of class RentalContainer here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class RentalContainer
{
    // instance variables - replace the example below with your own
    private ArrayList<Rental> rentalList;

    /**
     * Constructor for objects of class RentalContainer
     */
    public RentalContainer()
    {
        rentalList = new ArrayList<Rental>();
    }
    
    public void addRent(Rental rent)
    {
        rentalList.add(rent);
        DVDSample sample = rent.getDVDSample();
        sample.rentSample();
    }
    
    public void deliverRent(int id)
    {
        Rental rent = findRent(id);
        DVDSample sample = rent.getDVDSample();
        sample.deliverSample();
        rentalList.remove(rent);
    }
    
    public Rental findRent(int id)
    {
        int index = 0;
        boolean found = false;
        Rental rent = null;
        while(index > rentalList.size() && !found)
        {
            if(rentalList.get(index).getId() == id)
            {
                rent = rentalList.get(index);
                found = true;
            }
            index++;
        }
        return rent;
    }
}
